App({

  /**
   * 当小程序初始化完成时，会触发 onLaunch（全局只触发一次）
   */
  onLaunch: function () {
    wx.cloud.init({
      traceUser: true,
    })

    const api = require('./api/api');
    api.callfun("userLogin").then(res => {
      wx.setStorageSync('appid', res.result.appid);
      wx.setStorageSync('openid', res.result.openid);
    })

    wx.getSystemInfo({
      success: e => {
        this.globalData.StatusBar = e.statusBarHeight;
        let page = wx.getSystemInfoSync();
        let capsule = wx.getMenuButtonBoundingClientRect();
        if (capsule) {
          this.globalData.Custom = capsule;
          //顶部状态栏和功能栏高度
          this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight + 2;
          //顶部功能栏里的文字高度
          this.globalData.CustomTitle = this.globalData.CustomBar / 1.7;
          //页面除去状态栏和功能栏的高度
          this.globalData.CustomPage = page.windowHeight - this.globalData.CustomBar - 20;
        } else {
          this.globalData.CustomBar = e.statusBarHeight + 50;
        }
      }
    })
  },
  globalData: {},

  /**
   * 当小程序启动，或从后台进入前台显示，会触发 onShow
   */
  onShow: function (options) {

  },

  /**
   * 当小程序从前台进入后台，会触发 onHide
   */
  onHide: function () {

  },

  /**
   * 当小程序发生脚本错误，或者 api 调用失败时，会触发 onError 并带上错误信息
   */
  onError: function (msg) {

  }
})